import React, { useEffect } from 'react';
import Timetable from './page/TimeTable';
import rootData from './static';
export default function App() {
  useEffect(() => {
    let beforeTime = JSON.parse(localStorage.getItem('ClearanceTime'));
    let timestamp = Date.now(); //当前时间戳
    let week = new Date(timestamp).getDay(); //星期几
    let ClearanceTime = { timestamp, week };

    if (beforeTime) {
      //如果过了一天
      if (timestamp - beforeTime.timestamp > 24 * 60 * 60 * 1000) {
        if (week < beforeTime.week) {
          console.time('隔一星期重置数据开始!');
          localStorage.setItem('memorandumData', JSON.stringify(rootData));
          localStorage.setItem('ClearanceTime', JSON.stringify(ClearanceTime));
          console.timeEnd('隔一星期重置数据成功!');
        }
      }
    } else {
      localStorage.setItem('ClearanceTime', JSON.stringify(ClearanceTime));
    }
  }, []);

  return (
    <>
      <Timetable />
    </>
  );
}
